﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VipCo.Entities;
using VipCo.Data;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for BindCatalog
/// </summary>
public class BindCatalog
{
    public BindCatalog()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public static void BindNhomSanPham(DropDownList cboCatalog)
    {
        TList<NhomChuyenMuc> TList_Catalog = DataRepository.NhomChuyenMucProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenChuyenMuc";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Nhóm Sản Phẩm --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }

    public static void BindThanhPho(DropDownList cboCatalog)
    {
        TList<ThanhPho> TList_Catalog = DataRepository.ThanhPhoProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenThanhPho";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Thành Phố --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }
    public static void BindQuanHuyen(DropDownList cboCatalog)
    {
        TList<QuanHuyen> TList_Catalog = DataRepository.QuanHuyenProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenQuanHuyen";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Quận Huyện --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }

    public static void BindTinTuc(DropDownList cboCatalog)
    {
        TList<NhomTinTuc> TList_Catalog = DataRepository.NhomTinTucProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenNhom";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Tin Tức --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }

    public static void BindSubTinTuc(DropDownList cboCatalog, int idNhomTinTuc)
    {
        int totalRows = 0;
        string whereClause = "TrangThai = 1 and IdNhomTinTuc = " + idNhomTinTuc;
        TList<SubTinTuc> TList_Catalog = DataRepository.SubTinTucProvider.GetPaged(whereClause, "Id DESC", 0, 0, out totalRows);
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenSubTinTuc";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Sub Tin Tức --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }

    public static void BindLoaiThe(DropDownList cboCatalog)
    {
        TList<LoaiThe> TList_Catalog = DataRepository.LoaiTheProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenLoaiThe";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Loại Thẻ --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }

    public static void BindTenDiaDiem(DropDownList cboCatalog)
    {
        TList<DiaDiem> TList_Catalog = DataRepository.DiaDiemProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_Catalog;
        cboCatalog.DataTextField = "TenDiaDiem";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Tên địa điểm --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }
    public static void BindNhomQuangCao(DropDownList cboCatalog)
    {
        TList<NhomQuangCao> TList_NhomQuangCao = DataRepository.NhomQuangCaoProvider.Find("TrangThai=True");
        cboCatalog.DataSource = TList_NhomQuangCao;
        cboCatalog.DataTextField = "Ten";
        cboCatalog.DataValueField = "Id";
        cboCatalog.DataBind();
        ListItem ItemChoose = new ListItem();
        ItemChoose.Text = " -- Nhóm quảng cáo --";
        ItemChoose.Value = "0";
        cboCatalog.Items.Insert(0, ItemChoose);
    }
}